<html>
<head><meta charset="utf-8"><title>captures-trait · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html">captures-trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="148060451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148060451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148060451">(Nov 20 2018 at 19:15)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Have you seen <a href="https://github.com/rust-lang/rust/pull/56047" target="_blank" title="https://github.com/rust-lang/rust/pull/56047">https://github.com/rust-lang/rust/pull/56047</a> yet BTW? I was hoping to get some clarification on <a href="https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999" target="_blank" title="https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999">https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999</a> from you if that's alright.</p>



<a name="148066267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148066267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148066267">(Nov 20 2018 at 20:38)</a>:</h4>
<p><span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> I had not seen that -- I do actually think we should try to solve this at the language level</p>



<a name="148075495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148075495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148075495">(Nov 20 2018 at 23:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> oh I see</p>



<a name="148075549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148075549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148075549">(Nov 20 2018 at 23:10)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> what do you think the approach should be then?</p>



<a name="148123639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148123639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148123639">(Nov 21 2018 at 17:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> hey, around by chance?</p>



<a name="148124047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148124047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148124047">(Nov 21 2018 at 17:09)</a>:</h4>
<p>sort of</p>



<a name="148124989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148124989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148124989">(Nov 21 2018 at 17:24)</a>:</h4>
<p><span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> what's up</p>



<a name="148125007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125007">(Nov 21 2018 at 17:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> wanted to get your thoughts on the lifetime capturing issue if you have a minute</p>



<a name="148125014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125014">(Nov 21 2018 at 17:25)</a>:</h4>
<p>ah</p>



<a name="148125015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125015">(Nov 21 2018 at 17:25)</a>:</h4>
<p>re that comment of yours, from a while back</p>



<a name="148125025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125025">(Nov 21 2018 at 17:25)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999" target="_blank" title="https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999">https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999</a></p>



<a name="148125114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125114">(Nov 21 2018 at 17:27)</a>:</h4>
<p>left a <a href="https://github.com/rust-lang/rust/pull/56047#issuecomment-440748053" target="_blank" title="https://github.com/rust-lang/rust/pull/56047#issuecomment-440748053">quick comment on the RFC</a></p>



<a name="148125128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125128">(Nov 21 2018 at 17:27)</a>:</h4>
<p>the tl;dr is that <code>Captures</code> is not something I want users to have to think about :)</p>



<a name="148125131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125131">(Nov 21 2018 at 17:27)</a>:</h4>
<p>but I'm not sure what is the best way to fix</p>



<a name="148125133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125133">(Nov 21 2018 at 17:27)</a>:</h4>
<p>or to <em>think</em> about the fix, that is</p>



<a name="148125181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125181">(Nov 21 2018 at 17:28)</a>:</h4>
<p>we could certainly make the compiler accept the code</p>



<a name="148125187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125187">(Nov 21 2018 at 17:28)</a>:</h4>
<p>I am...like 99.5% sure that would be fine :) but I'm nervous about accepting a bit too much</p>



<a name="148125389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125389">(Nov 21 2018 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> yeah...</p>



<a name="148125397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125397">(Nov 21 2018 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> "The key thing here is that TyCtxt is invariant w/r/t 'tcx and 'gcx, so they must appear in the return type." -- could you clarify why they <em>must</em> appear in the return type because they're invariant?</p>



<a name="148125495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125495">(Nov 21 2018 at 17:34)</a>:</h4>
<p>but generally, behaviour akin to <code>dyn Trait</code> sounds sensible to me</p>



<a name="148125496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125496">(Nov 21 2018 at 17:34)</a>:</h4>
<p>well</p>



<a name="148125506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125506">(Nov 21 2018 at 17:35)</a>:</h4>
<p>let's say the type was <code>&amp;'a T</code></p>



<a name="148125509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125509">(Nov 21 2018 at 17:35)</a>:</h4>
<p>in that case, there is a subtyping relationship: <code>&amp;'a T &lt;:  &amp;'b T</code> if <code>'a: 'b</code></p>



<a name="148125514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125514">(Nov 21 2018 at 17:35)</a>:</h4>
<p>in other words, you can view a <code>&amp;'a T</code> as an <code>&amp;'b T</code> where <code>'b</code> is some shorter lifetime</p>



<a name="148125569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125569">(Nov 21 2018 at 17:36)</a>:</h4>
<p>however, you cannot view a <code>TyCtxt&lt;.., 'gcx, 'tcx&gt;</code> as a <code>TyCtxt&lt;.., 'gcx1, 'tcx1&gt;</code> where <code>'[gt]cx1</code> are shorter</p>



<a name="148125577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125577">(Nov 21 2018 at 17:36)</a>:</h4>
<p>this is because we have shared, mutable state in the <code>TyCtxt</code> (e.g., <code>RefCell&lt;HashMap&lt;..&gt;&gt;</code>)</p>



<a name="148125590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125590">(Nov 21 2018 at 17:36)</a>:</h4>
<p>if you were to just approximate the <code>'tcx</code> lifetime, you could store some random stuff from your stack into one of those hashmaps</p>



<a name="148125618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125618">(Nov 21 2018 at 17:37)</a>:</h4>
<p>point is, if we are trying to view a <code>&amp;'a T</code> as a <code>Foo&lt;'b&gt;</code> where the hidden type is <code>&amp;'b u32</code>, that's ok</p>



<a name="148125628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125628">(Nov 21 2018 at 17:37)</a>:</h4>
<p>since everything of type <code>&amp;'a T</code> is <em>also</em> of type <code>&amp;'b T</code> (so long as <code>'b</code> is shorter)</p>



<a name="148125695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125695">(Nov 21 2018 at 17:38)</a>:</h4>
<p>(if it helps, think of Java: basically, if the hidden type were Object, it'd be ok to put a String in there)</p>



<a name="148125698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125698">(Nov 21 2018 at 17:38)</a>:</h4>
<p>(because a String <em>is</em> an Object)</p>



<a name="148125765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125765">(Nov 21 2018 at 17:39)</a>:</h4>
<p>hmmm</p>



<a name="148125834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148125834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148125834">(Nov 21 2018 at 17:40)</a>:</h4>
<p>I know what invariant means, but why <em>must</em> they appear in the return type <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ?</p>



<a name="148126105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148126105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148126105">(Nov 21 2018 at 17:44)</a>:</h4>
<p>point is: the return type is some supertype of <code>TyCtxt&lt;'tcx&gt;</code> (ignoring the others for now since they don't matter)</p>



<a name="148126112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148126112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148126112">(Nov 21 2018 at 17:45)</a>:</h4>
<p>but all such supertypes still talk about <code>'tcx</code></p>



<a name="148126123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148126123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148126123">(Nov 21 2018 at 17:45)</a>:</h4>
<p>or <code>'gcx</code>, whichever one we are trying to hide</p>



<a name="148126125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148126125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148126125">(Nov 21 2018 at 17:45)</a>:</h4>
<p>so, the hidden type will always include <code>'gcx</code></p>



<a name="148126205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148126205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148126205">(Nov 21 2018 at 17:46)</a>:</h4>
<p>makes sense <span class="user-mention" data-user-id="116009">@nikomatsakis</span>.  but then why are we allowed to do it with <code>dyn Trait</code>, which is also a supertype, surely?</p>



<a name="148128845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128845">(Nov 21 2018 at 18:29)</a>:</h4>
<p>it is not a supertype</p>



<a name="148128923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128923">(Nov 21 2018 at 18:30)</a>:</h4>
<p>you can construct a <code>dyn (Trait + 'b)</code> from any type <code>T</code> where (a) <code>T: Trait</code> and <code>T: 'b</code> (there is always a bound <code>'b</code>, though it often defaults to <code>'static</code>)</p>



<a name="148128932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128932">(Nov 21 2018 at 18:30)</a>:</h4>
<p>in other words, converting into a <code>dyn Trait</code> loses static type information</p>



<a name="148128938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128938">(Nov 21 2018 at 18:30)</a>:</h4>
<p>we don't know exactly which lifetimes are contained within</p>



<a name="148128949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128949">(Nov 21 2018 at 18:30)</a>:</h4>
<p>this is not true for <code>impl Trait</code>, actually, at least not <em>presently</em></p>



<a name="148128980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148128980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148128980">(Nov 21 2018 at 18:31)</a>:</h4>
<p>I think the "proper" way to view this is that we would have some kind of "exists&lt;'gcx: 'tcx&gt; T` operator that lets you hide a lifetime from any type</p>



<a name="148131766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148131766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148131766">(Nov 21 2018 at 19:21)</a>:</h4>
<p>yeah, I discussed that with @centril before briefly. I think we could even reuse <code>for&lt;&gt;</code>?</p>



<a name="148131777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/148131777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#148131777">(Nov 21 2018 at 19:21)</a>:</h4>
<p>and good point about it not being a supertype</p>



<a name="156400638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/captures-trait/near/156400638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/captures-trait.html#156400638">(Jan 18 2019 at 21:21)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> some prior discussion I just remembered, if you're interested. ^</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>